//
//  DateReserveCell.swift
//  EyeVisionForPatients
//
//  Created by QDSG on 2020/2/26.
//  Copyright © 2020 tao Tao. All rights reserved.
//

import UIKit

struct DateWeekModel {
    var yearMonthDay: String = ""
    /// eg. 2-14
    var monthDay: String = ""
    /// eg. 周一
    var weekDay: String = ""
    /// eg. am-上午 pm-下午
    var timeInterval: String = ""
    
    var timeIntervalStr: String {
        if timeInterval == "am" {
            return "上午"
        } else if timeInterval == "pm" {
            return "下午"
        } else {
            return ""
        }
    }
}

class SERegistrationDateCell: UICollectionViewCell {

    static let className = "SERegistrationDateCell"
    static let reuseId = className

    @IBOutlet weak var alldateLabel: UILabel! {
        didSet {
            alldateLabel.text = "全部\n日期"
        }
    }

    @IBOutlet weak var weekLabel: UILabel!

    @IBOutlet weak var dateLabel: UILabel!

    @IBOutlet weak var usableLabel: UILabel!

    override func awakeFromNib() {
        super.awakeFromNib()
        self.layer.cornerRadius = 5
        self.layer.masksToBounds = true
    }
    
    func configure(with model: SERegistrationDateModel, indexPath: IndexPath) {
        switch indexPath.item {
        case 0:
            alldateLabel.isHidden = false
            weekLabel.isHidden = true
            dateLabel.isHidden = true
            usableLabel.isHidden = true
        default:
            alldateLabel.isHidden = true
            weekLabel.isHidden = false
            dateLabel.isHidden = false
            usableLabel.isHidden = false
            weekLabel.text = model.week
            dateLabel.text = model.time
            usableLabel.text = model.val == 0 ? "无号" : "有号"
        }
    }
    
    func setSelected(reset: Bool) {
        if reset {
            backgroundColor = UIColor.init(hex: "F8F9FA")
            weekLabel.textColor = Asset.textLight.color
            dateLabel.textColor = Asset.textDark.color
            usableLabel.textColor = usableLabel.text == "有号" ?  Asset.textDark.color : UIColor.init(hex: "#F7B500")
            alldateLabel.textColor = Asset.black.color
        } else {
            backgroundColor = Asset.main.color
            weekLabel.textColor = Asset.white.color
            dateLabel.textColor = Asset.white.color
            usableLabel.textColor = usableLabel.text == "有号" ?  Asset.white.color : UIColor.init(hex: "#F7B500")
            alldateLabel.textColor = UIColor.white
        }
    }
}
